<template>
  <div class="goodMessageItem">
    <div class="rating-time">{{ratingTime(item.rateTime)}}</div>
    <div class="rating-content">
      <span class="icon-thumb_down" :class="(item.rateType === 0) && 'icon-thumb_up'"></span>
      <span class="rating-info">{{item.text}}</span>
    </div>
    <div class="avatar">
      <div class="avatar-name">{{item.username}}</div>
      <div class="avatar-icon">
        <img :src="item.avatar" alt="">
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "goodMessageItem",
  props: {
    item: {
      type: Object
    }
  },
  methods: {
    formatTime(time) {
      if(time > 0 && time < 10) {
        return "0" + time;
      } else {
        return time
      }
    },
    ratingTime(time) {
      var date = new Date(time);
      var year = this.formatTime(date.getFullYear());
      var month = this.formatTime(date.getMonth() + 1);
      var day = this.formatTime(date.getDate());
      var hour = this.formatTime(date.getHours());
      var minutes = this.formatTime(date.getMinutes());
      return year + "-" + month + "-" + day + " " + hour + ":" + minutes;
    }
  }
}
</script>

<style lang="stylus" ref="stylesheet/stylus">
@import '../assets/stylus/index.styl';

</style>


